from django.views import View
from django.http import JsonResponse
import logging
import traceback

from big_screen.utils import sys_setting as code
from big_screen.redisOpration.AllOpration import isworkingOp

Helog = logging.getLogger("Heartbeat")
errlog = logging.getLogger("Process")
lnlog = logging.getLogger("Lnglat")


# Create your views here.
# √
class IsWrokon(View):
    @classmethod
    def post(cls, request):
        """
        心跳包存储
        :param request:
        :return:
        """
        # ---------------------- 接收数据 ----------------------
        ret = eval(request.body.decode())
        # ----------------------- 心跳包redis仓库操作类 --------------------
        iw = isworkingOp()
        # ---------------------- 存入redis ---------------------------
        k, v = iw.formatter_info(ret)
        iw.list_push(k, v)
        # --------------------- 返回 ---------------------------------
        return JsonResponse(code.con)
